package com.gexiaobao.pigeon.ui.adapter

import android.annotation.SuppressLint
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.IncomeList
import com.gexiaobao.pigeon.databinding.ItemInconmeBinding

/**
 * @Author      : hxw
 * @Date        : 2024/7/19 13:45
 * @Describe    :
 */
class AdapterIncome(data: ArrayList<IncomeList>) : BaseQuickAdapter<IncomeList, DataBindBaseViewHolder>(R.layout.item_inconme, data) {
    @SuppressLint("NotifyDataSetChanged")
    override fun convert(holder: DataBindBaseViewHolder, item: IncomeList) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemInconmeBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        holder.setGone(R.id.tvItemIncomeNoData, item.list.isNotEmpty())
        holder.setGone(R.id.llListGroup, item.list.isEmpty())

        holder.itemView.apply {
            binding.swipeRecyclerView.adapter = null
            val mAdapter = AdapterAboutPassSignProject()
            mAdapter.setList(item.list)
            binding.swipeRecyclerView.apply {
                layoutManager = LinearLayoutManager(context)
                adapter = mAdapter
                mAdapter.notifyDataSetChanged()
            }
        }
    }
}